#ifndef UART_H
#define UART_H

#include <sys/types.h>
#include <stdint.h>
#include <reent.h>

#include "stm32f10x_it.h"
#include "stm32f10x.h"
#include "stm32f10x_conf.h"

extern void  uart_init(int baudrate);
extern void  uart_poll_send(const char *s);
extern int   uart_chars_avail(void);

extern ssize_t uart_write_r(struct _reent *r, int fd, const void *ptr, size_t len);
extern ssize_t uart_read_r(struct _reent *r, int fd, void *ptr, size_t len);


//#define MESSAGE_INFO		0//String
//#define MESSAGE_WARNING		1//String
//#define MESSAGE_ERROR		2//String
//
//#define MESSAGE_ACC			10//3 x int16
//#define MESSAGE_GYRO		11//3 x int16
//#define MESSAGE_PHI			12//1 x int32
//#define MESSAGE_PHI_ZERO	13//no data
//
//#define MESSAGE_INCREM			20//uint64
//#define MESSAGE_SPEED			21//uint64
//#define MESSAGE_SPEED_MATLAB	22//uint64
//#define MESSAGE_SERVO_MATLAB	23//uint64
//
//#define MESSAGE_RECEIVE_SPEED  90
//#define MESSAGE_RECEIVE_SERVO  91
//
//#define MESSAGE_AD_MEASURE	 30//uint64
//#define MESSAGE_CONTROLLER	 33//uint64
//#define MESSAGE_CURRENT_LINE 34//uint64
//
//#define MESSAGE_BATTERY		41//2x uint16 in mV
//#define MESSAGE_RUNTIME		42//str
//
//#define MESSAGE_UH			60//4db int32
//
//
//#define MESSAGE_STATE		70//String
//#define MESSAGE_LINE		71//String
//
//#define MESSAGE_FRONT_1		50//60 x float
//#define MESSAGE_FRONT_2		51//60 x float
//#define MESSAGE_FRONT_3		52//60 x float
//#define MESSAGE_FRONT_4		53//51 x float
//
//#define MESSAGE_REAR_1		54//60 x float
//#define MESSAGE_REAR_2		55//60 x float
//#define MESSAGE_REAR_3		56//60 x float
//#define MESSAGE_REAR_4		57//51 x float
//
//#define MESSAGE_INFRA_MORE	58//
//
//#define MESSAGE_SPEED_SELECTOR 		92
//#define MESSAGE_CASCADE_MULTIPLIER  93

void UART_Create_Message(uint16_t Type, uint8_t * data, uint16_t Length);
void UART_Init(int baudrate);
void UART_SendData(const uint8_t *data, uint16_t size);
void UART_ReceiveTask(void);

#endif
